package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Complaints;
import com.ruoyi.system.service.IComplaintsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 投诉处理Controller
 * 
 * @author zyq
 * @date 2024-06-29
 */
@RestController
@RequestMapping("/system/complaints")
public class ComplaintsController extends BaseController
{
    @Autowired
    private IComplaintsService complaintsService;

    /**
     * 查询投诉处理列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Complaints complaints)
    {
        startPage();
        List<Complaints> list = complaintsService.selectComplaintsList(complaints);
        return getDataTable(list);
    }

    /**
     * 导出投诉处理列表
     */

    @PostMapping("/export")
    public void export(HttpServletResponse response, Complaints complaints)
    {
        List<Complaints> list = complaintsService.selectComplaintsList(complaints);
        ExcelUtil<Complaints> util = new ExcelUtil<Complaints>(Complaints.class);
        util.exportExcel(response, list, "投诉处理数据");
    }

    /**
     * 获取投诉处理详细信息
     */
    @GetMapping(value = "/{complaintsId}")
    public AjaxResult getInfo(@PathVariable("complaintsId") Long complaintsId)
    {
        return success(complaintsService.selectComplaintsByComplaintsId(complaintsId));
    }

    /**
     * 新增投诉处理
     */

    @PostMapping
    public AjaxResult add(@RequestBody Complaints complaints)
    {
        return toAjax(complaintsService.insertComplaints(complaints));
    }

    /**
     * 修改投诉处理
     */

    @PutMapping
    public AjaxResult edit(@RequestBody Complaints complaints)
    {
        return toAjax(complaintsService.updateComplaints(complaints));
    }

    /**
     * 删除投诉处理
     */

	@DeleteMapping("/{complaintsIds}")
    public AjaxResult remove(@PathVariable Long[] complaintsIds)
    {
        return toAjax(complaintsService.deleteComplaintsByComplaintsIds(complaintsIds));
    }
}
